package net.liteheaven.dtimer.timer

import android.app.job.JobParameters
import android.app.job.JobService
import android.os.Build
import android.support.annotation.RequiresApi
import net.liteheaven.dtimer.XLog
import net.liteheaven.dtimer.timer.DTimerConst.Companion.EXTRA_TIMER_ID

/**
 * Created by LiangYu on 2018/7/27.
 */
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
class DTimerJobService : JobService() {

    override fun onStartJob(params: JobParameters?): Boolean {
        if (params != null) {
            val jobId = params.jobId
            XLog.i("==>onStartJob id = $jobId")
            val timerId = params.extras.getInt(EXTRA_TIMER_ID)
            DTimerManager.dispatch(timerId)
        }
        return false
    }

    override fun onStopJob(params: JobParameters?): Boolean {
        XLog.i("<==onStopJob")
        return false
    }
}